
<%@page import="study.itwill.team5.admin.AdminItem"%>
<%@page import="study.itwill.jsp.WebHandler"%>
<%@page import="study.itwill.team5.member.MemberItem"%>
<%@page import="study.itwill.team5.member.Member"%>
<%@page import="study.itwill.common.PatternChecker"%> 
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ page session="true" %>
<%
   WebHandler web = new WebHandler(request, response, out);
   AdminItem loginInfo = (AdminItem)session.getAttribute("ADMIN_INFO");
   
   // 로그인 정보가 없을 경우 로그인 페이지로 이동
   if (loginInfo == null) {
	   web.goPage("/italia/login.jsp", "로그인이 필요합니다");
      return;
   }
%>
<%
	String seq = request.getParameter("seq");

	if (!PatternChecker.isValue(seq)) {
		out.print("<script type='text/javascript'>alert('뷰 파라미터가 없습니다.');history.back();</script>");
		return;
	}
	if (!PatternChecker.isNum(seq)) {
		out.print("<script type='text/javascript'>alert('뷰 파라미터가 부정확합니다.');history.back();</script>");
		return;
	}

	int Member_number = Integer.parseInt(seq);
%>
<%@ include file="../dbcon.jsp"%>
<%
	/** 학생데이터 조회 */
	Member member = new Member();
	MemberItem item = member.viewMember(Member_number);

	 

	if (item == null) {
		out.print("<script type='text/javascript'>alert('데이터 조회에 실패했습니다. 잠시후 다시 시도해 주세요.')");
		return;
	}
%>
<!DOCTYPE html>
<html lang="ko">
<head>
<%@ include file="../head.jsp"%>
</head>
<body>
	<%@ include file="../menu.jsp"%>
	
	<div class="container">
		<div class="page-header">
			<h1>회원 정보 보기</h1>
		</div>

		<form id="frmMemberView" class="form-horizontal" role="form"
			method="post" action=""> 
			 <input type="hidden" name="seq" value="<%=seq%>">
			
			<fieldset>

				<!-- 입력양식 -->
				<div class="form-group">
					<label for="email1" class="col-md-2 control-label">이메일1</label>
					<div class="col-md-10">
						<p class="form-control-static"><%=item.getEmail1()%><%="@"%><%=item.getEmail2()%></p>
					</div>
				</div>
				 			

				<div class="form-group">
					<label for="nickname" class="col-md-2 control-label">아이디</label>
					<div class="col-md-10">
						<p class="form-control-static"><%=item.getNickname()%></p>
					</div>
				</div>
 
				<div class="form-group">
					<label for="user_pw" class="col-md-2 control-label">비밀번호</label>
					<div class="col-md-10">
						<p class="form-control-static">
							<small>비밀번호는 암호화되어 표시되지 않습니다.</small>
						</p>
					</div>
				</div>

				<div class="form-group">
					<label for="gender" class="col-md-2 control-label">성별</label>
					<div class="col-md-10">
						<p class="form-control-static"><%
								if (item.getGender().equals("M")) {
									out.print("남자");
								} else if (item.getGender().equals("F")) {
									out.print("여자");
								}
						%></p>
					</div>
				</div>

				<div class="form-group">
					<label for="birthday" class="col-md-2 control-label">생년월일</label>
					<div class="col-md-10">
						<p class="form-control-static"><%=item.getBirthday().substring(0,10)%></p>
					</div>
				</div>

				<div class="form-group">
					<label for="hp1" class="col-md-2 control-label">연락처</label>
					<div class="col-md-10">
						<p class="form-control-static"><%=item.getHp1()%>-<%=item.getHp2()%>-<%=item.getHp3()%></p>
					</div>
				</div>
				
				
					<div class="form-group">
					<label for="reg_date" class="col-md-2 control-label">등록일자</label>
					<div class="col-md-10">
						<p class="form-control-static"><td><%=item.getReg_date().substring(0, 4)%>-<%=item.getReg_date().substring(4, 6)%>-<%=item.getReg_date().substring(6, 8)%>&nbsp;<%=item.getReg_date().substring(8, 10)%>:<%=item.getReg_date().substring(10, 12)%>:<%=item.getReg_date().substring(12, 14)%></td></p>
					</div>
				</div>
				
				<div class="form-group">
					<label for="edit_date" class="col-md-2 control-label">수정일자</label>
					<div class="col-md-10">
						<p class="form-control-static"><td><%=item.getEdit_date().substring(0, 4)%>-<%=item.getEdit_date().substring(4, 6)%>-<%=item.getEdit_date().substring(6, 8)%>&nbsp;<%=item.getEdit_date().substring(8, 10)%>:<%=item.getEdit_date().substring(10, 12)%>:<%=item.getEdit_date().substring(12, 14)%></td></p>
					</div>
				</div>
				
				 

				<div class="form-group">
					<div class="col-md-offset-2 col-md-10">
						<div class="row">
							<div class="col-md-4">
								<a href="listMember.jsp" class="btn btn-primary btn-block">목록보기</a>
							</div>
							<div class="col-md-4">
								<button type="submit" id="edit" formaction="editMember.jsp"
									formmethod="post"
									class="btn btn-info btn-block">수정하기</button>
							</div>
							<div class="col-md-4">
								<button type="submit" id="delete" 
								formaction="deletMemberOk.jsp" 
								formmethod="post"
								class="btn btn-danger btn-block">삭제하기</button>
							</div>
						</div>
					</div>
				</div>

			</fieldset>
		</form>
	</div>
<% DBHandler.disconnect(); %>
	<!-- Javascript -->
	<script src="/italia/assets/js/jquery.js"></script>
	<script src="/italia/assets/js/bootstrap.min.js"></script>
 
	<script type="text/javascript">
		$(function() {
			// id속성이 "delete"인 요소에 대한 click이벤트
			$("#delete").click(function() {
				if(!confirm("정말 삭제하시겠습니까?")) {
					//취소를 선택한 경우 처리 중단
					return false;
				}
			});
		});
		
			</script>
  </body>
</html>